﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ShootThemUp
{
    class Player : Acteur
    {
        //Le nb de vie me sert de multiplicateur de dégat
        public const int DAMAGE = 1000;
        public const int NBVIESMAX = 5;
        public int Vie { get; set; }
        public List<Bonus> LsBonus { get; set; }

        public Player(Texture2D texture, Point vitesse) : base(new Vector2(100, Controleur.CADRE_JEU.Height - texture.Height - 10), texture, vitesse)
        {
            LsBonus = new List<Bonus>();
            Vie = 0;
        }

        public void goDroite()
        {
            Position = new Vector2(Position.X + Vitesse.X, Position.Y);
        }

        public void goGauche()
        {
            Position = new Vector2(Position.X - Vitesse.X, Position.Y);
        }

        public List<Tir> tire(Texture2D textureTir, GameTime gameTime)
        {
            List<Tir> tirs = new List<Tir>();
            Controleur.DateDernierTir += gameTime.ElapsedGameTime;
            if (Controleur.DateDernierTir >= Controleur.LIMITE_TIR)
            {
                if (LsBonus.Count > 0)
                {
                    Tir tir1 = new Tir(new Vector2(Position.X - 2, Position.Y - 8), textureTir, new Point(0, 7));
                    Tir tir2 = new Tir(new Vector2(Position.X + 22, Position.Y - 8), textureTir, new Point(0, 7));
                    tirs.Add(tir1);
                    tirs.Add(tir2);
                }
                else
                {
                    Tir tir = new Tir(new Vector2(Position.X + 10, Position.Y - 18), textureTir, new Point(0, 7));
                    tirs.Add(tir);
                }
                Controleur.DateDernierTir = new TimeSpan();
            }
            return tirs;
        }
    }
}
